#ifndef _DOMINION_HELPERS_H
#define _DOMINION_HELPERS_H

#include "dominion.h"
#include "interface.h"
#include <stdlib.h>

#define DEFAULT_STREAM 0

// Something like this should probably be in dominion.h
enum PHASE {
    action = 0,
    buy,
    cleanup,
};

enum CARDTYPE {
    treasure_t,
    kingdom_t,
    kingdom_victory_t,
    victory_t,
    curse_t,
    trash_t,
};

void init_cards(int *cards);
void copy_state(struct gameState *dest, struct gameState *src);
void shuffle_game(int player, struct gameState *state);
void randState(struct gameState *state, int mandatory_card, int phase);
int get_card_type(int card);
int is_valid_game_state(struct gameState *state);
int drawCard(int player, struct gameState *state);
int updateCoins(int player, struct gameState *state, int bonus);
int discardCard(int handPos, int currentPlayer, struct gameState *state,
                int trashFlag);
int gainCard(int supplyPos, struct gameState *state, int toFlag, int player);
int getCost(int cardNumber);
int cardEffect(int card, int choice1, int choice2, int choice3,
               struct gameState *state, int handPos, int *bonus);
int get_first_in_pile(int *pile, int pile_size, int card);
int count_cards(int *pile, int pile_size, int card);
int count_cards_of_type(int *pile, int pile_size, int card_t);
int get_total_card_counts(struct gameState *state, int card_counts[NUM_TOTAL_K_CARDS]);

// Testing helper functions
void fill_array(int *s, int v, size_t n);
int ops_hand_counts(int player, struct gameState *state);
int ops_deck_counts(int player, struct gameState *state);
int ops_discard_counts(int player, struct gameState *state);
void replace_card(int player, struct gameState *state, int from, int to);
void iter_deck(int player, struct gameState *state, void (*func)(int));
void iter_hand(int player, struct gameState *state, void (*func)(int));
void iter_discard(int player, struct gameState *state, void (*func)(int));
void print_card(int card);
int count_in_hand(int player, struct gameState *state, int card);
int randRange(int lhs, int rhs);
int randCard(void);
int numersort(const void *lhs, const void *rhs);
int compare_cards(int *to, int to_count, int *from, int from_count);

// From dominion.c
int compare(const void* a, const void* b);
#endif
